//1. cpu内存
console.log(process.memoryUsage());
console.log(process.cpuUsage());

// 2.运行环境，node环境，cpu架构，用户环境，系统平台
// console.log(process.cwd());
// console.log(process.version);
// console.log(process.versions);
// console.log(process.arch);
// console.log(process.env.NODE_ENV);
// console.log(process.env.PATH);
// console.log(process.env.HOME); //mac 使用HOME  window使用USERPROFILE
// console.log(process.platform);

// 3.运行状态  启动参数、PID、运行时间
console.log(process.argv);
console.log(process.argv0);

console.log(process.pid);

console.log(process.uptime());

// 4.时间监听
// process.on("exit", (code) => {
//   console.log("exit" + code);
// });

// process.on("beforeExit", (code) => {
//   console.log("beforeExit" + code);
// });

// console.log("代码执行完毕 ");

// process.exit(); //只会走exit的监听事件 不走beforeExit

// 5. 标准输出 输入 错误
// console.log = function (data) {
//   process.stdout.write("---" + data + "\n");
// };

const fs = require("fs");

fs.createReadStream("text.txt").pipe(process.stdout);

// process.stdin.pipe(process.stdout);

process.stdin.setEncoding("utf-8");
process.stdin.on("readable", () => {
  let chunk = process.stdin.read();
  process.stdout.write("data" + chunk);
});
